<?php 
namespace Admin\Controller;
//use Think\Controller;
use Tools\AdminController;
class AuthController extends AdminController {
    
//    获取所有权限
    public function showlist(){
//    访问过滤
            $auth =  D('Auth')->order('auth_path')->select();
            $this->assign('auth',$auth);
            $this->display();
    }
//    权限添加
    public function tianjia(){
        $auth = new \Model\AuthModel();
        if(IS_POST){
//          dump($_POST);4条信息(name,pid,controller,action);auth_path和auth_level通过算法实现
            $z = $auth->saveData($_POST);
            if($z){
                $this->redirect('showlist',array(),2,'添加成功');
            }else{
                $this->redirect('tianjia',array(),2,'添加失败');
            }
        }else{
//          获取上级权限信息
            $authinfo = $auth->where('auth_level=0')->select();
//          print_r($authinfo);
            $this->assign('auths',$authinfo);
            $this->display();   
        }
    }
}





